![]() |
PATH![]() |
There are two functions to deal with the differences in byte ordering between the Intel platform and Mac OS platform. The USB uses Intel byte ordering (called little endian) on all multibyte fields, which is reversed from the Mac OS byte ordering (called big endian, because the most significant byte appears at the lowest memory address). These functions are of endian neutral form. Using these functions correctly allows the code to be recompiled on an Intel endian platform and still work as expected.
All parameters and parameter block elements are automatically swapped by the USB Services Library. These functions need be used only for data that the USL has no knowledge of. This includes all descriptors returned from the descriptor functions.
If you need to embed a 16-bit USB constant in your code, you can use this macro:
USB_CONSTANT16(x)
This macro is only useful for the C or C++ programming languages.
The HostToUSBWord function changes the byte order of a value from big endian to little endian.
UInt16 HostToUSBWord(UInt16 value)
The USBToHostWord function changes the byte order of a value from little endian to big endian.
UInt16 USBToHostWord(UInt16 value)
If you need to embed a 16-bit USB constant in your code, you can use this macro:
USB_CONSTANT16(x)
This macro is only useful for the C or C++ programming languages.
Previous | Back Up One Level | Next |